/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package nc.bs.mo.mo2010;

import java.util.ArrayList;
import javax.naming.NamingException;
import nc.bs.logging.Logger;
import nc.bs.mm.pub.pub1020.DisassembleDMO;
import nc.bs.mo.mo2010.Disassemble;
import nc.bs.pub.SystemException;
import nc.vo.mm.pub.pub1020.ProduceCoreVO;
import nc.vo.mm.pub.pub1030.PickmHeaderVO;
import nc.vo.mm.pub.pub1030.PickmItemVO;
import nc.vo.mm.pub.pub1030.PickmVO;
import nc.vo.mt.mt1004.ConsumeVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;

public class ConsumeDisassemble extends Disassemble {
	private ConsumeVO[] cvos = null;

	public ConsumeDisassemble(String pk_corp, String gcbm, String date)
			throws NamingException, SystemException {
		super(pk_corp, gcbm, date);
	}

	public ConsumeDisassemble(String pk_corp, String gcbm, String date,
			ConsumeVO[] cvos) throws NamingException, SystemException {
		super(pk_corp, gcbm, date);
		this.cvos = cvos;
	}

	protected PickmVO disassemble(PickmHeaderVO headVO)
			throws BusinessException {
		PickmVO pickmvo = new PickmVO();
		pickmvo.setParentVO(headVO);
		ArrayList list = new ArrayList();

		for (int vos = 0; vos < this.cvos.length; ++vos) {
			PickmItemVO vo = new PickmItemVO();
			vo.setPk_corp(headVO.getPk_corp());
			vo.setGcbm(headVO.getGcbm());
			vo.setFxid(headVO.getWlbmid());
			vo.setFlrq(new UFDate(headVO.getLogDate()));
			vo.setPk_produce(this.cvos[vos].getPk_produce());
			vo.setWlbmid(this.cvos[vos].getPk_invbasdoc());
			vo.setJldwid(this.cvos[vos].getPk_measdoc());
			ProduceCoreVO produceVO = null;

			try {
				produceVO = (new DisassembleDMO()).getFjldwInfo(vo.getWlbmid());
			} catch (Exception arg7) {
				Logger.error(arg7.getMessage(), arg7);
				return null;
			}

			vo.setClbm(produceVO.getInvcode());
			vo.setClmc(produceVO.getInvname());
			vo.setClgg(produceVO.getInvspec());
			vo.setClxh(produceVO.getInvtype());
			vo.setWlth(produceVO.getGraphid());
			vo.setJldwmc(produceVO.getMeasname());
			vo.setFjldwid(produceVO.getFjldwid());
			vo.setFjldwmc(produceVO.getFjldwmc());
			vo.setFixedflag(produceVO.getFixedflag());
			vo.setFjlhsl(produceVO.getMainmeasrate());
			vo.setSfdc(this.cvos[vos].getSfdc());
			vo.setGroupno(this.cvos[vos].getGroupno());
			vo.setExchgattr(this.cvos[vos].getExchgattr());
			vo.setExchgattrmc(this.cvos[vos].getExchgattrdesc());
			vo.setBlly(this.cvos[vos].getBlly());
			vo.setMaterclass(new Integer(0));
			vo.setGylx(new Integer(0));
			vo.setXelwfw(new UFDouble(0));
			vo.setTdbz(new Integer(0));
			vo.setKzbz(new Integer(1));
			vo.setZxlx(new Integer(0));
			vo.setSfATPjc(new UFBoolean(false));
			vo.setSfzl(new UFBoolean(false));
			vo.setBlfs(new Integer(3));
			vo.setSfkfl(new UFBoolean(true));
			vo.setDwde(this.cvos[vos].getNum());
			vo.setDeyl(this.cvos[vos].getNum());
			vo.setJhcksl(this.cvos[vos].getNum());
			if (headVO.getFjhwgsl() != null) {
				vo.setFdwde(this.cvos[vos].getFnum());
				vo.setFdeyl(this.cvos[vos].getFnum());
				vo.setFjhcksl(this.cvos[vos].getFnum());
			}

			vo.setLjcksl(new UFDouble(0));
			vo.setLjyfsl(new UFDouble(0));
			vo.setStatus(2);
			vo.setZyx1(headVO.getZyx1());
			vo.setZyx2(headVO.getZyx2());
			vo.setZyx3(headVO.getZyx3());
			vo.setZyx4(headVO.getZyx4());
			vo.setZyx5(headVO.getZyx5());
			list.add(vo);
		}

		PickmItemVO[] arg8 = new PickmItemVO[list.size()];
		list.toArray(arg8);
		pickmvo.setChildrenVO(arg8);
		return pickmvo;
	}
}